﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace LinqToLfsWorld.Utility
{

	/// <summary>
	/// Reads the ident key from the first line in the specified file.
	/// </summary>
	public class IdentKeyReader
	{
		/// <summary>
		/// Reads the key from the local file.
		/// </summary>
		/// <param name="filename">The filename.</param>
		public static string ReadKey(string filename)
		{
			if (filename == null)
				throw new ArgumentNullException("filename");

			string key = string.Empty;

			using (FileStream fs = new FileStream(filename, FileMode.Open))
			{
				using (StreamReader reader = new StreamReader(fs))
				{
					// The key should exist on the first line.
					key = reader.ReadLine();
				}
			}

			return key;
		}
	}
}
